<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <table border="1">
        <caption>我的微博</caption>
        <tr><th>id</th><th>微博正文</th><th>发布时间</th><th>操作</th></tr>
        <tr v-for="weibo in arr">
            <td>{{weibo.id}}</td>
            <td>{{weibo.content}}</td>
            <td>{{weibo.created}}</td>
            <td><a href="#" @click="del(weibo.id)">删除</a></td>
        </tr>
    </table>
</div>
<!--引入vue-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<!--引入axios框架-->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<!--引入处理时间格式的js文件-->
<script src="http://cdn.staticfile.org/moment.js/2.24.0/moment.js"></script>
<script>
    let vm = new Vue({
        el:"#app",
        data:{
            arr:[]
        },
        created:function () {
            axios.get("/selectMyWeibo").then(function (response) {
                vm.arr = response.data;
                for (let weibo of vm.arr) {
                    weibo.created = moment(weibo.created).format("YYYY/MM/DD HH:mm:ss");
                }
            })
        },
        methods:{
            del:function (id) {
                if(confirm("您确认删除此微博吗?")){
                    axios.get("/delete?id="+id).then(function () {
                        location.reload();
                    })
                }

            }
        }
    })
</script>
</body>
</html>